exports.main = async (context) => {
    const param = context.data
    if (!param.dbOp || !param.collectionName) {
        throw 'incorrect parameter'
    }
    const cloud = context.cloud
    const collection = cloud.db.collection(param.collectionName);
    switch(param.dbOp) {
        case 'find': {
            return await collection.find(param.filter, param.operation)
        }
        case 'count': {
            return await collection.count(param.filter)
        }
        default:
            throw 'incorrect dbOp:' + param.dbOp
    }
};